package org.gnyxy.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.gnyxy.dto.CartInfoDTO;
import org.gnyxy.entity.CartInfo;
import org.gnyxy.vo.CartDishInfoVO;
import org.gnyxy.vo.CartWithInfoVO;

import java.util.List;

@Mapper
public interface CartInfoMapper {
    @Insert("insert into cart_info(cart_id, dish_id, material_id, material_number, is_main, deleted) " +
            "values (#{cartId},#{dishId},#{materialId},#{materialNumber},#{isMain},#{deleted})")
    void insertOne(CartInfo cartInfo);

    void insert(List<CartInfo> cartInfos);

    List<CartInfo> getByCartIds(List<Long> cartIds);
    List<CartDishInfoVO> getByCartId(Long cartId);

    void update(CartInfoDTO cartInfoDTO);

    @Select("select * from cart_info where deleted = 0 and cart_id = #{cartId}")
    List<CartInfo> getInfosByCartId(Long cartId);

//    void delete(CartInfo cartInfo);

//    @Select("select * from cart_info where deleted = 0 and dish_id = #{dishId}")
//    List<CartInfo> getByDishId(Long dishId);

//    @Update("update cart_info set deleted = 1 where dish_id = #{dishId}")
//    void deleteByDishIdAndUserId(Long dishId);

    void delete(List<CartInfo> cartInfos);

    @Update("update cart_info set deleted = 1 where cart_id = #{cartId}")
    void deleteByCartId(Long cartId);

    void deleteByCartIds(List<Long> cartIds);

    List<CartInfo> getByDishIds(List<Long> dishIds);
}
